// import axios from "axios";
import { getProductListByParams  } from "@/api/api";
export default {
  name: 'autotrophy',
  components: {}, 
  props: [],
  data () {
    return {
      pageNo: 1,
      pagesize: 10,
      total:0,
      formauto:{
      },
       options: [{
          value: '选项1',
          label: '黄金糕'
        }, {
          value: '选项2',
          label: '双皮奶'
        }, {
          value: '选项3',
          label: '蚵仔煎'
        }, {
          value: '选项4',
          label: '龙须面'
        }, {
          value: '选项5',
          label: '北京烤鸭'
        }],
        value: '',
        list:[],
        // 分页
        
        // 数据
         tableData: [],
      tableData: [{
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-04',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1517 弄'
      }, {
        date: '2016-05-01',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1519 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }],
         params:{
           selectType:0,
           keyword:"",
           types: "",
           address: "",
           company:"",
         }
    }
  },
  computed: {

  },
  created(){
    this._getautData()
  },
  mounted () {

  },
  methods: {
    // 数据渲染
    _getautData(){
      this.params['pageNo'] = this.pageNo;
      this.params['pageSize'] = this.pageSize;
      getProductListByParams(this.params).then((res)=>{
      console.log(res)
        this.tableData = res.data
      // this.list  = res.data
        this.total = res.total;

      })
    },
    // 分类添加
    change(type1,item){
      // alert(1)
      if(type1===1){
        this.params.types =item
      }else if(type1 === 2){
        this.params.address = item
        
      }else if(type1 === 3){
        this.params.company = item
        
      }
    },
    // 搜索
    search(){
      this._getautData()
    },
    // 分类方式
    sendway(){
      this._getautData()
      
    },
    // 上下页
    goPrev(){
      let current = this.pageNo -1;
      this.pageNo--;
      if(current == 0){
        this.pageNo = 1;
        current = 1;
        return 
      }
      this._getautData()
    },
    goNext(){
      // let current = this.pageNo +1;
      this.pageNo++;
      this._getautData()
    },
    handleSizeChange(val){
      this._getautData()
    },
    handleCurrentange(val){
    // var pageNo = $(val)
    this.$nextTick(()=>{
      this._getautData()      
    })
        
      
      
    }
  }
}
